/**
 * @author zyj
 * @date 2022年06月06日 15:11
 */
public class 守护线程 {
    public static void main(String[] args) {
        Thread t1 = new Thread("线程A"){
            @Override
            public void run() {
                while (true){
                    System.out.println(Thread.currentThread().getName() + ":" + System.currentTimeMillis());
                    try {
                        sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        t1.setDaemon(true);
        t1.start();
        try {
            Thread.sleep(5000);
            System.out.println(Thread.currentThread().getName() + ":" + System.currentTimeMillis());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
